<?php
$active = Utils::get_param('active', 0);
$system_id = Utils::get_param('sys', 0);

$opts = new stdClass();
$opts->cd = 't.id = :v1';
$opts->cdv = array(':v1' => $system_id);
$data = $orm->get('pb_sys', NULL, NULL, NULL, NULL, $opts)->d;

$themes = $orm->get('pb_theme', 't.folder', 'ASC', NULL , NULL, NULL)->d;

$opts = new stdClass();
$opts->cd = 't.sys_id = :v1';
$opts->cdv = array(':v1' => $system_id);
$opts->sel = 't.id, t.parent_id, t.name, t.order, t.is_default, t.is_visible, t.sys_id';
$pages = $orm->get('pb_page', 't.order', 'ASC', NULL, NULL, $opts)->d;
?>
<button onclick="$.blockUI();location.href = '?d=' + __dir;" class="pure-button pure-button-active pure-button-bk">&nbsp;&nbsp;All Systems</button>
<div id="tabs" style="width: 740px; margin-top:  5px;" class="pure-skin-mine_tp">
  <ul>
    <li id="tab_system" onclick="Url.insert_param('active', 0);"><a href="#system" id="tab_sys"></a></li>
    <li id="tab_pages" onclick="Url.insert_param('active', 1);"><a href="#pages">Pages</a></li>
  </ul>
  <div id="system"><?php include 'index_system.inc.system.php'; ?></div>
  <div id="pages"><?php include 'index_system.inc.pages.php'; ?></div>
</div>

<script type="text/javascript">
  var __data = JSON.parse('<?php echo addslashes(json_encode($data)); ?>');
  var __themes = JSON.parse('<?php echo addslashes(json_encode($themes)); ?>');
  var __pages = JSON.parse('<?php echo addslashes(json_encode($pages)); ?>');
  var __root = Utils.get_root(__pages);
  var __install_url = '<?php echo URL . INSTALL_DIR; ?>';
  var __home_url = '<?php echo URL . HOME_DIR; ?>';
  var __dir = '<?php echo $dir; ?>';
  var __file = '<?php echo $file; ?>';
  var __active = '<?php echo $active; ?>';

  $(function(){
    $( "#bk_systems" ).button({
      icons: {
        primary: "ui-icon-arrowthick-1-w"
      }
    })
    
    $("#tabs").tabs({ collapsible: true, active: __active, show: { effect: "blind", duration: 300 }, heightStyle: 'content' });
    init_system();
    init_pages();
  });
</script>

